'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var arrayOrder = [{
    orderNumber: 'QD053210034',
    date1: '2018-08-10',
    state: '待支付'
}, {
    orderNumber: 'QD053210035',
    date1: '2018-08-11',
    state: '待支付'
}, {
    orderNumber: 'QD053210036',
    date1: '2018-08-12',
    state: '已支付'
}];

function addNone(tableOrderBox) {
    var tableOrderBoxEvent = tableOrderBox.forEach(function (r) {
        r.classList.add('none');
    });
    return tableOrderBoxEvent;
}

var clickEvent = function () {
    function clickEvent() {
        _classCallCheck(this, clickEvent);
    }

    _createClass(clickEvent, [{
        key: 'clickOrderCollection',
        value: function clickOrderCollection() {
            if (document.querySelector('.orderCollection') != undefined) {
                var orderCollection = es('.orderCollection');

                var orderCollectionEvent = orderCollection.forEach(function (r) {

                    r.addEventListener('click', function (event) {
                        var self = event.currentTarget,
                            text = self.children[0],
                            img = self.children[1];

                        if (img.style.webkitTransform !== 'rotateX(180deg)') {
                            var show = new showTable();
                            show.retractOrderCollection(img, text);
                            show.retractAllTable(self, true);
                        } else {
                            var _show = new showTable();
                            _show.showOrderCollection(img, text);
                            _show.retractAllTable(self, false);
                        }
                    });
                });
                return orderCollectionEvent;
            }
        }
    }, {
        key: 'clickRetract',
        value: function clickRetract() {
            if (document.querySelector('.orderCollection') != undefined) {
                if (document.querySelector('.retract') != undefined) {
                    var retract = es('.retract');

                    var retractEvent = retract.forEach(function (r) {

                        r.addEventListener('click', function (event) {
                            var self = event.currentTarget,
                                tableAllBox = self.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode,
                                orderCollection = tableAllBox.children[0].children[3],
                                text = orderCollection.children[0],
                                img = orderCollection.children[1];

                            if (img.style.webkitTransform !== 'rotateX(180deg)') {
                                var show = new showTable();
                                show.retractTable(self);
                                show.retractOrderCollection(img, text);
                            } else {
                                var _show2 = new showTable();
                                _show2.retractTable(self);
                                _show2.retractOrderCollection(img, text);
                            }
                        });
                    });
                    return retractEvent;
                }
            } else {
                if (document.querySelector('.retract') != undefined) {
                    var _retract = es('.retract');

                    var _retractEvent = _retract.forEach(function (r) {

                        r.addEventListener('click', function (event) {
                            var self = event.currentTarget,
                                img = self.children[0];

                            if (img.style.webkitTransform !== 'rotateX(180deg)') {
                                var show = new showTable();
                                show.retractTable(self);
                            } else {
                                var _show3 = new showTable();
                                _show3.retractTable(self);
                            }
                        });
                    });
                    return _retractEvent;
                }
            }
        }
    }, {
        key: 'clickChangeP',
        value: function clickChangeP() {
            if (document.querySelector('.clickChangeP') != undefined) {
                var clickChangeP = es('.clickChangeP');

                var clickChangePEvent = clickChangeP.forEach(function (r) {
                    var reviseP = r.parentNode.children[1];
                    r.addEventListener('click', function () {

                        reviseP.contentEditable = true;
                        if (window.getSelection) {
                            //ie11 10 9 ff safari
                            reviseP.focus();
                            var range = window.getSelection(); //创建range
                            range.selectAllChildren(reviseP); //range 选择obj下所有子内容
                            range.collapseToEnd(); //光标移至最后
                        } else if (document.selection) {
                            //ie10 9 8 7 6 5
                            var range = document.selection.createRange(); //创建选择对象
                            //var range = document.body.createTextRange();
                            range.moveToElementText(reviseP); //range定位到obj
                            range.collapse(false); //光标移至最后
                            range.select();
                        }
                        reviseP.onblur = function () {
                            reviseP.contentEditable = false;
                        };
                    });
                });
                return clickChangePEvent;
            }
        }
    }, {
        key: 'clickSureChange',
        value: function clickSureChange() {
            if (document.querySelector('.sureChange') != undefined) {
                var sureChange = e('.sureChange');
                sureChange.onclick = function () {
                    swal('成功！', '您已修改成功！', 'success');
                };
            }
        }
    }, {
        key: 'clickPutOrder',
        value: function clickPutOrder() {
            if (document.querySelector('.putOrder') != undefined) {
                var putOrder = e('.putOrder');
                putOrder.onclick = function () {
                    swal('成功！', '您已提交订单！', 'success').then(function () {
                        // setTimeout(function() {
                        window.location.href = "shoppingList.html";
                        // }, 2000)
                    });
                };
            }
        }
    }, {
        key: 'clickCheckbox',
        value: function clickCheckbox() {
            if (document.querySelector('#allCheckbox') != undefined) {
                var checkbox = e('#allCheckbox'),
                    checkInput = es('.checkbox');

                checkbox.onclick = function () {
                    var checkInputEvents = checkInput.forEach(function (r) {
                        r.checked = checkbox.checked;
                    });
                    return checkInputEvents;
                };
            }
        }
    }, {
        key: 'clickSearch',
        value: function clickSearch() {
            if (document.querySelector('.orderSearch') != undefined) {
                var orderSearch = e('.orderSearch'),
                    tableproduct = es('.tableproduct'),
                    tableOrderBox = es('.tableOrderBox'),
                    tableBox = e('.tableBox');

                orderSearch.onclick = function () {
                    var search_text = e('#search_text').value,
                        dateSelect = e('#dateSelect').innerText;
                    addNone(tableOrderBox);
                    var tableproductEvent = tableOrderBox.forEach(function (r) {

                        var num = r.children[0].children[1].children[0].children[0].children[1].innerText,
                            date = r.children[0].children[1].children[0].children[0].children[4].innerText,
                            pay = r.children[0].children[1].children[0].children[0].children[6].innerText;
                        log('date', date, 'num', num, 'pay', pay, 'search_text', search_text, 'dateSelect', dateSelect);
                        log('judgedate', dateSelect == date && search_text == num);
                        log('judgedate||', dateSelect == date || search_text == num);

                        // if (search_text != '' && dateSelect != '') {

                        if (dateSelect == date && search_text == num) {
                            // tableBox.innerHTML = ''
                            // tableBox.appendChild(r.parentNode)
                            r.classList.remove('none');
                            log('r', r);
                        } else if (dateSelect != date && search_text == num || dateSelect == date && search_text != num) {
                            r.classList.remove('none');
                            log('222222');
                        }
                        //  else if (dateSelect == date && search_text != num) {
                        //     r.parentNode.parentNode.classList.remove('none')
                        // }
                        // }
                    });
                    return tableproductEvent;
                };
            }
        }
    }, {
        key: 'clickAllOrder',
        value: function clickAllOrder() {
            if (document.querySelector('.allOrder') != undefined) {
                var allOrder = e('.allOrder'),
                    buttonTab = es('.buttonTab'),
                    showTabClass = new showTab(),
                    innerHtmlClass = new innerHtml(),
                    tableBox = e('.tableBox');

                allOrder.onclick = function () {
                    showTabClass.showOrderTab(buttonTab, allOrder);
                    tableBox.innerHTML = '';
                    innerHtmlClass.innerHtmlAllOrder();
                };
            }
        }
    }, {
        key: 'clickNeedPay',
        value: function clickNeedPay() {
            if (document.querySelector('.obligation') != undefined) {
                var allOrder = e('.obligation'),
                    buttonTab = es('.buttonTab'),
                    showTabClass = new showTab(),
                    innerHtmlClass = new innerHtml(),
                    tableBox = e('.tableBox');

                allOrder.onclick = function () {
                    showTabClass.showOrderTab(buttonTab, allOrder);
                    tableBox.innerHTML = '';
                    innerHtmlClass.innerHtmlNeedPay();
                };
            }
        }
    }]);

    return clickEvent;
}();

var filterArray = function () {
    function filterArray() {
        _classCallCheck(this, filterArray);
    }

    _createClass(filterArray, [{
        key: 'filterNeedPay',
        value: function filterNeedPay(array) {
            var arr = [];
            array.map(function (r) {
                if (r.state == '待支付') {
                    arr.push(r);
                }
            });
            return arr;
        }
    }]);

    return filterArray;
}();

var innerHtml = function () {
    function innerHtml() {
        _classCallCheck(this, innerHtml);
    }

    _createClass(innerHtml, [{
        key: 'innerHtmlAllOrder',
        value: function innerHtmlAllOrder() {
            var tableBox = e('.tableBox');

            arrayOrder.map(function (r) {
                var num = r.orderNumber,
                    date = r.date1,
                    state = r.state;

                var t = '\n                <div class="tableOrderBox">\n                    <div class="tableproductBox">\n                        <div class="borderLine absolute-left-center"></div>\n                        <table class="tableproduct">\n                            <tr>\n                                <td class="tableOrderTitle1" rowspan="5"><input class="checkbox" type="checkbox" name="" value=""></td>\n                                <td class="tableOrderTitle2" rowspan="5">' + num + '</td>\n                                <td class="tableOrderTitle3">\u6743\u9650\u4E2D\u5FC3</td>\n                                <td class="tableOrderTitle3">\u57FA\u7840\u529F\u80FD</td>\n                                <td class="tableOrderTitle5" rowspan="5">' + date + '</td>\n                                <td class="tableOrderTitle6" rowspan="5">2019-02-15</td>\n                                <td class="tableOrderTitle3" rowspan="5">' + state + '</td>\n                                <td class="tableOrderTitle8" rowspan="5">\u7EED\u8D39/\u65B0\u8D2D</td>\n                                <td class="tableOrderTitle3" rowspan="5">10000\u5143</td>\n                                <td class="tableOrderTitle10" rowspan="5">\u652F\u4ED8/\u5220\u9664</td>\n                                <td class="tableOrderTitle11 retract" rowspan="5" align="center">\u6536\u8D77&ensp;<img src="../static/img/shoppingCart/down.png" alt=""></td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                        </table>\n                    </div>\n                    <div class="tableproductBox none">\n                        <div class="borderLine absolute-left-center"></div>\n                        <table class="tableproduct">\n                            <tr style="border: 1px solid #05577b;">\n                                <td class="tableOrderTitle1" rowspan="5"><input class="checkbox" type="checkbox" name="checkbox" value=""></td>\n                                <td class="tableOrderTitle2" rowspan="5">' + num + '</td>\n                                <td class="tableOrderTitle3" style="color: #999;">\u2014\u2014</td>\n                                <td class="tableOrderTitle3">\u57FA\u7840\u529F\u80FD</td>\n                                <td class="tableOrderTitle5" rowspan="5">' + date + '</td>\n                                <td class="tableOrderTitle6" rowspan="5">2019-02-15</td>\n                                <td class="tableOrderTitle3" rowspan="5">' + state + '</td>\n                                <td class="tableOrderTitle8" style="color: #999;" rowspan="5">\u2014\u2014</td>\n                                <td class="tableOrderTitle3" rowspan="5">10000\u5143</td>\n                                <td class="tableOrderTitle10" style="color: #999;" rowspan="5">\u2014\u2014</td>\n                                <td class="tableOrderTitle11 retract" rowspan="5" align="center">\u5C55\u5F00&ensp;<img style="-webkit-transform:rotateX(180deg);-ms-transform:rotateX(180deg);transform:rotateX(180deg)" src="../static/img/shoppingCart/down.png" alt=""></td>\n                            </tr>\n                        </table>\n                    </div>\n                </div>\n            ';
                tableBox.insertAdjacentHTML('beforeend', t);
            });
            var clickEvents = new clickEvent();
            clickEvents.clickRetract();
            clickEvents.clickCheckbox();
            clickEvents.clickAllOrder();
            clickEvents.clickSearch();
        }
    }, {
        key: 'innerHtmlNeedPay',
        value: function innerHtmlNeedPay() {
            var tableBox = e('.tableBox'),
                filterArrayClass = new filterArray(),
                array = filterArrayClass.filterNeedPay(arrayOrder);

            array.map(function (r) {
                var num = r.orderNumber,
                    date = r.date1,
                    state = r.state;

                var t = '\n                <div class="tableOrderBox">\n                    <div class="tableproductBox">\n                        <div class="borderLine absolute-left-center"></div>\n                        <table class="tableproduct">\n                            <tr>\n                                <td class="tableOrderTitle1" rowspan="5"><input class="checkbox" type="checkbox" name="" value=""></td>\n                                <td class="tableOrderTitle2" rowspan="5">' + num + '</td>\n                                <td class="tableOrderTitle3">\u6743\u9650\u4E2D\u5FC3</td>\n                                <td class="tableOrderTitle3">\u57FA\u7840\u529F\u80FD</td>\n                                <td class="tableOrderTitle5" rowspan="5">2018-08-10</td>\n                                <td class="tableOrderTitle6" rowspan="5">2019-02-15</td>\n                                <td class="tableOrderTitle3" rowspan="5">' + state + '</td>\n                                <td class="tableOrderTitle8" rowspan="5">\u7EED\u8D39/\u65B0\u8D2D</td>\n                                <td class="tableOrderTitle3" rowspan="5">10000\u5143</td>\n                                <td class="tableOrderTitle10" rowspan="5">\u652F\u4ED8/\u5220\u9664</td>\n                                <td class="tableOrderTitle11 retract" rowspan="5" align="center">\u6536\u8D77&ensp;<img src="../static/img/shoppingCart/down.png" alt=""></td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                            <tr>\n                                <td>\u6743\u9650\u4E2D\u5FC3</td>\n                                <td>\u57FA\u7840\u529F\u80FD</td>\n                            </tr>\n                        </table>\n                    </div>\n                    <div class="tableproductBox none">\n                        <div class="borderLine absolute-left-center"></div>\n                        <table class="tableproduct">\n                            <tr style="border: 1px solid #05577b;">\n                                <td class="tableOrderTitle1" rowspan="5"><input class="checkbox" type="checkbox" name="checkbox" value=""></td>\n                                <td class="tableOrderTitle2" rowspan="5">' + num + '</td>\n                                <td class="tableOrderTitle3" style="color: #999;">\u2014\u2014</td>\n                                <td class="tableOrderTitle3">\u57FA\u7840\u529F\u80FD</td>\n                                <td class="tableOrderTitle5" rowspan="5">' + date + '</td>\n                                <td class="tableOrderTitle6" rowspan="5">2019-02-15</td>\n                                <td class="tableOrderTitle3" rowspan="5">' + state + '</td>\n                                <td class="tableOrderTitle8" style="color: #999;" rowspan="5">\u2014\u2014</td>\n                                <td class="tableOrderTitle3" rowspan="5">10000\u5143</td>\n                                <td class="tableOrderTitle10" style="color: #999;" rowspan="5">\u2014\u2014</td>\n                                <td class="tableOrderTitle11 retract" rowspan="5" align="center">\u5C55\u5F00&ensp;<img style="-webkit-transform:rotateX(180deg);-ms-transform:rotateX(180deg);transform:rotateX(180deg)" src="../static/img/shoppingCart/down.png" alt=""></td>\n                            </tr>\n                        </table>\n                    </div>\n                </div>\n            ';
                tableBox.insertAdjacentHTML('beforeend', t);
            });
            var clickEvents = new clickEvent();
            clickEvents.clickRetract();
            clickEvents.clickCheckbox();
            clickEvents.clickAllOrder();
            clickEvents.clickSearch();
        }
    }]);

    return innerHtml;
}();

var showTab = function () {
    function showTab() {
        _classCallCheck(this, showTab);
    }

    _createClass(showTab, [{
        key: 'showOrderTab',
        value: function showOrderTab(buttonTab, allOrder) {
            var buttonTabEvent = buttonTab.forEach(function (r) {
                if (r.classList.contains('choose1')) {
                    r.classList.remove('choose1');
                    allOrder.classList.add('choose1');
                }
            });
            return buttonTabEvent;
        }
    }]);

    return showTab;
}();

var showTable = function () {
    function showTable() {
        _classCallCheck(this, showTable);
    }

    _createClass(showTable, [{
        key: 'retractTable',
        value: function retractTable(a) {
            var parent = a.parentNode.parentNode.parentNode.parentNode.parentNode,
                hidden = parent.children[0],
                show = parent.children[1];

            if (show.classList.contains('none')) {
                hidden.classList.add('none');
                show.classList.remove('none');
            } else {
                hidden.classList.remove('none');
                show.classList.add('none');
            }
        }
    }, {
        key: 'retractAllTable',
        value: function retractAllTable(a, b) {
            var parent = a.parentNode.parentNode,
                tableBox = parent.children[2].children;

            for (var i = 0; i < tableBox.length; i++) {
                var r = tableBox[i],
                    show = r.children[1],
                    hidden = r.children[0];
                if (show.classList.contains('none') && b) {
                    hidden.classList.add('none');
                    show.classList.remove('none');
                } else {
                    hidden.classList.remove('none');
                    show.classList.add('none');
                }
            }
        }
    }, {
        key: 'retractOrderCollection',
        value: function retractOrderCollection(img, text) {
            img.style.webkitTransform = 'rotateX(180deg)';
            img.style.msTransform = 'rotateX(180deg)';
            img.style.transform = 'rotateX(180deg)';
            text.innerHTML = '查看详情';
        }
    }, {
        key: 'showOrderCollection',
        value: function showOrderCollection(img, text) {
            img.style.webkitTransform = 'rotateX(0deg)';
            img.style.msTransform = 'rotateX(0deg)';
            img.style.transform = 'rotateX(0deg)';
            text.innerHTML = '订单收起';
        }
    }]);

    return showTable;
}();

var time1;

function isCompanyNumber() {
    time1 = setInterval(function () {
        var inputUserName = e('#inputCompany').value;
        var judgeInput = e('#inputCompany').parentNode.children[2];
        var pattern = /^[A-Za-z0-9]+$/;
        if (pattern.test(inputUserName)) {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/true.png" alt="">';
        } else {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/wrong.png" alt="">';
        }
    }, 100);
}

var time2;

function isChinaName() {
    time2 = setInterval(function () {
        var inputUserName = e('#inputName').value;
        var judgeInput = e('#inputName').parentNode.children[2];
        var pattern = /^[\u4e00-\u9fa5_a-zA-Z0-9]+$/;
        if (pattern.test(inputUserName)) {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/true.png" alt="">';
        } else {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/wrong.png" alt="">';
        }
    }, 100);
}

// 验证手机号
var time3;

function isPhone() {
    time3 = setInterval(function () {
        var inputPhoneNumber = e('#inputPhoneNumber').value;
        var judgeInput = e('#inputPhoneNumber').parentNode.children[2];
        var pattern = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
        if (pattern.test(inputPhoneNumber)) {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/true.png" alt="">';
        } else {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/wrong.png" alt="">';
        }
    }, 100);
}

// 验证手机号
var time5;

function isPhone1() {
    time5 = setInterval(function () {
        var inputPhoneNumber = e('#inputPhoneNumber1').value;
        var judgeInput = e('#inputPhoneNumber1').parentNode.children[2];
        var pattern = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
        if (pattern.test(inputPhoneNumber)) {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/true.png" alt="">';
        } else {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/wrong.png" alt="">';
        }
    }, 100);
}

// 验证手机号
var time4;

function isJob() {
    time4 = setInterval(function () {
        var inputPhoneNumber = e('#inputJob').value;
        var judgeInput = e('#inputJob').parentNode.children[2];
        var pattern = /^[\u4e00-\u9fa5_a-zA-Z0-9]+$/;
        if (pattern.test(inputPhoneNumber)) {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/true.png" alt="">';
        } else {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/wrong.png" alt="">';
        }
    }, 100);
}

// 验证邮箱
var time6;

function isEmail() {
    time6 = setInterval(function () {
        var inputPhoneNumber = e('#inputEmail').value;
        var judgeInput = e('#inputEmail').parentNode.children[2];
        var pattern = /^([A-Za-z0-9_\-\.\u4e00-\u9fa5])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/;
        if (pattern.test(inputPhoneNumber)) {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/true.png" alt="">';
        } else {
            judgeInput.innerHTML = '<img src="../static/img/myFactory/wrong.png" alt="">';
        }
    }, 100);
}

function companynumberonblur() {
    clearInterval(time1);
}

function nameonblur() {
    clearInterval(time2);
}

function phoneonblur() {
    clearInterval(time3);
}

function phoneonblur1() {
    clearInterval(time5);
}

function jobonblur() {
    clearInterval(time4);
}

function emailonblur() {
    clearInterval(time6);
}

//测试用的数据，这里可以用AJAX获取服务器数据
var test_list = ["QD053210034", "QD053210035", "QD053210036"];
var old_value = "";
var highlightindex = -1; //高亮
//自动完成
function AutoComplete(auto, search, mylist) {
    if ($("#" + search).val() != old_value || old_value == "") {
        var autoNode = $("#" + auto); //缓存对象（弹出框）
        var carlist = new Array();
        var n = 0;
        old_value = $("#" + search).val();
        for (i in mylist) {
            if (mylist[i].indexOf(old_value) >= 0) {
                carlist[n++] = mylist[i];
            }
        }
        if (carlist.length == 0) {
            autoNode.hide();
            return;
        }
        autoNode.empty(); //清空上次的记录
        for (i in carlist) {
            var wordNode = carlist[i]; //弹出框里的每一条内容
            var newDivNode = $("<div>").attr("id", i); //设置每个节点的id值
            newDivNode.attr("style", "font:14px/25px arial;height:25px;padding:0 8px;cursor: pointer;");
            newDivNode.html(wordNode).appendTo(autoNode); //追加到弹出框
            //鼠标移入高亮，移开不高亮
            newDivNode.mouseover(function () {
                if (highlightindex != -1) {
                    //原来高亮的节点要取消高亮（是-1就不需要了）
                    autoNode.children("div").eq(highlightindex).css("background-color", "white");
                }
                //记录新的高亮节点索引
                highlightindex = $(this).attr("id");
                $(this).css("background-color", "#ebebeb");
            });
            newDivNode.mouseout(function () {
                $(this).css("background-color", "white");
            });
            //鼠标点击文字上屏
            newDivNode.click(function () {
                //取出高亮节点的文本内容
                var comText = autoNode.hide().children("div").eq(highlightindex).text();
                highlightindex = -1;
                //文本框中的内容变成高亮节点的内容
                $("#" + search).val(comText);
            });
            if (carlist.length > 0) {
                //如果返回值有内容就显示出来
                autoNode.show();
            } else {
                //服务器端无内容返回 那么隐藏弹出框
                autoNode.hide();
                //弹出框隐藏的同时，高亮节点索引值也变成-1
                highlightindex = -1;
            }
        }
    }
    //点击页面隐藏自动补全提示框
    document.onclick = function (e) {
        var e = e ? e : window.event;
        var tar = e.srcElement || e.target;
        if (tar.id != search) {
            if ($("#" + auto).is(":visible")) {
                $("#" + auto).css("display", "none");
            }
        }
    };
}

var searchText = function searchText() {
    old_value = $("#search_text").val();
    $("#search_text").focus(function () {
        if ($("#search_text").val() == "") {
            AutoComplete("auto_div", "search_text", test_list);
        }
    });
    $("#search_text").keyup(function () {
        AutoComplete("auto_div", "search_text", test_list);
    });
};

var _main = function _main() {
    var clickEvents = new clickEvent();
    clickEvents.clickOrderCollection();
    clickEvents.clickRetract();
    clickEvents.clickChangeP();
    clickEvents.clickSureChange();
    clickEvents.clickPutOrder();
    clickEvents.clickCheckbox();
    clickEvents.clickAllOrder();
    clickEvents.clickNeedPay();
    clickEvents.clickSearch();
    laydate.render({
        elem: '#dateSelect' //指定元素
    });
    searchText();
};

_main();
